package com.spmsys.entity.sys;

import java.util.regex.Pattern;

/**
 * 用户实体类
 */
public class Users {
    private String id;
    private String owner;
    private String createBy;
    private String updateBy;
    private Long createAt;
    private Long updateAt;
    private String name;
    private String nick_name;
    private String email;
    private String phone;
    private String sex;
    private String area;
    private String address;
    private String user_desc;
    private Integer type;
    private Integer source;
    private String password;

    public Users() {
    }

    public Users(String id, String owner, String createBy, String updateBy, Long createAt, Long updateAt, String name, String nick_name, String email, String phone, String sex, String area, String address, String user_desc, Integer type, Integer source, String password) {
        this.id = id;
        this.owner = owner;
        this.createBy = createBy;
        this.updateBy = updateBy;
        this.createAt = createAt;
        this.updateAt = updateAt;
        this.name = name;
        this.nick_name = nick_name;
        this.email = email;
        this.phone = phone;
        this.sex = sex;
        this.area = area;
        this.address = address;
        this.user_desc = user_desc;
        this.type = type;
        this.source = source;
        this.password = password;
    }

    public String getId() {
        return id;
    }

    public String getOwner() {
        return owner;
    }

    public String getCreateBy() {
        return createBy;
    }

    public String getUpdateBy() {
        return updateBy;
    }

    public Long getCreateAt() {
        return createAt;
    }

    public Long getUpdateAt() {
        return updateAt;
    }

    public String getName() {
        return name;
    }

    public String getNick_name() {
        return nick_name;
    }

    public String getEmail() {
        return email;
    }

    public String getPhone() {
        return phone;
    }

    public String getSex() {
        return sex;
    }

    public String getArea() {
        return area;
    }

    public String getAddress() {
        return address;
    }

    public String getUser_desc() {
        return user_desc;
    }

    public Integer getType() {
        return type;
    }

    public Integer getSource() {
        return source;
    }

    public String getPassword() {
        return password;
    }

    public void setId(String id) {
        this.id = id;
    }

    public void setOwner(String owner) {
        this.owner = owner;
    }

    public void setCreateBy(String createBy) {
        this.createBy = createBy;
    }

    public void setUpdateBy(String updateBy) {
        this.updateBy = updateBy;
    }

    public void setCreateAt(Long createAt) {
        this.createAt = createAt;
    }

    public void setUpdateAt(Long updateAt) {
        this.updateAt = updateAt;
    }

    public void setName(String name) {
        String regex = "^[a-zA-Z][a-zA-Z0-9]{0,63}$";
        if (name != null && !Pattern.matches(regex, name)) {
            throw new RuntimeException("name格式错误，正则：" + regex);
        }
        this.name = name;
    }

    public void setNick_name(String nick_name) {
        this.nick_name = nick_name;
    }

    public void setEmail(String email) {
        String regex = "^(\\w+([-.][A-Za-z0-9]+)*){3,18}@\\w+([-.][A-Za-z0-9]+)*\\.\\w+([-.][A-Za-z0-9]+)*$";
        if (email != null && !Pattern.matches(regex, email)) {
            throw new RuntimeException("email格式错误，正则：" + regex);
        }
        this.email = email;
    }

    public void setPhone(String phone) {
        String regex = "^1[3-9]\\d{9}$";
        if (phone != null && !Pattern.matches(regex, phone)) {
            throw new RuntimeException("phone格式错误，正则：" + regex);
        }
        this.phone = phone;
    }

    public void setSex(String sex) {
        String regex = "(MAN|WOMAN|UNKNOWN)";
        if (sex != null && !Pattern.matches(regex, sex)) {
            throw new RuntimeException("sex格式错误，正则：" + regex);
        }
        this.sex = sex;
    }

    public void setArea(String area) {
        String regex = "^\\S+,\\S+,\\S+$";
        if (area != null && !Pattern.matches(regex, area)) {
            throw new RuntimeException("area格式错误，正则：" + regex);
        }
        this.area = area;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public void setUser_desc(String user_desc) {
        this.user_desc = user_desc;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    public void setSource(Integer source) {
        this.source = source;
    }

    public void setPassword(String password) {
        String regex = "^[a-zA-Z][a-zA-Z0-9]{0,63}$";
        if (password != null && !Pattern.matches(regex, password)) {
            throw new RuntimeException("password格式错误，正则：" + regex);
        }
        this.password = password;
    }
}
